package com.lmmob.autotest.uitest.controls;

import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;

public class RadioButton extends Control {
    private String label;

    public RadioButton(String label, WebDriver webDriver) {
        super(webDriver);
        this.label = label;
    }

    @Override
    protected String getSelfQuery() {
        return String.format(".query(\"radio[boxLabel='%s']\")[0]", this.label);
    }

    public void click() {
        WebElement element = findElement(By.id(getId())).findElement(By.tagName("input"));
        element.click();
    }

    @Override
    protected String getName() {
        return this.label;
    }
}
